package net.dgg.rz.customer;

import net.dgg.framework.tac.kafka.annotation.DggKafkaListener;
import net.dgg.rz.customer.vo.AfterSaleChangeStatusMessageVo;
import net.dgg.rz.production.exception.ProductOrderExcption;
import net.dgg.rz.production.service.ProductOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author 胡隆再
 * @date 2020/9/2 10:52
 */
@Component
public class AfterSaleKafkaCustomer {
    protected Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private ProductOrderService productOrderService;
    /**
     * @Description 售后单状态变更kafka：
     * @author 胡隆再
     * @date 2020/9/2
     * @param vo 
     * @return void
     */
    @DggKafkaListener(topicName="SYS_AFTER_SALE_ORDER_STATUS_CHANGE_KAFKA", groupId="SYS_AFTER_SALE_ORDER_STATUS_CHANGE_KAFKA_RZSC",threadNum=5,whichDataSource = 0)
    public void afterSaleStatus(AfterSaleChangeStatusMessageVo vo) {
        try {
            productOrderService.afterSaleStatus(vo);
            logger.error("订单{}消费售后单状态变更kafka成功", vo.getOrderNo());
        } catch (ProductOrderExcption e){
            logger.error("订单{}消费售后单状态变更kafka失败,原因:{}", vo.getOrderNo(), e.toString());
        } catch (Exception e) {
            logger.error("订单{}消费售后单状态变更kafka失败,原因:{}", vo.getOrderNo(), e.toString());
        }
    }
}
